/**
 * 
 */
package au.edu.swin.videoshop.persistence;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author julie
 *
 */
@Entity
@NamedQueries({
	@NamedQuery (
			name="findAllRentals", 
			query="SELECT r FROM RentalEntity r"
	),
	@NamedQuery (
			name="findRentalByTitleCopyId", 
			query="SELECT r FROM RentalEntity r WHERE r.titleCopy.titleCopyId=:titleCopyId"
	),
	@NamedQuery (
			name="findRentalsByStoreId", 
			query="SELECT r FROM RentalEntity r WHERE r.staff.store.storeId=:storeId"
	),
	@NamedQuery (
			name="findRentalsByStaffId", 
			query="SELECT r FROM RentalEntity r WHERE r.staff.staffId=:staffId"
	),
	@NamedQuery (
			name="findRentalsByCustomerId", 
			query="SELECT r FROM RentalEntity r WHERE r.customer.customerId=:customerId"
	),
	@NamedQuery (
			name="findRentalsByStatus", 
			query="SELECT r FROM RentalEntity r WHERE r.status=:status"
	)
})
@Table(name="RENTAL")
public class RentalEntity implements Serializable{
	private Long mRentalId;
	private TitleCopyEntity mTitleCopy;
	private StaffEntity mStaff;
	private CustomerEntity mCustomer;
	private BigDecimal mFirstCharge;
	private BigDecimal mFinalCharge;
	private Date mRentalDate;
	private Date mDueDate;
	private Date mReturnDate;
	private String mStatus;

	
	public RentalEntity() {
	}

	/**
	 * @return the customerId
	 */
	@Id
	@GeneratedValue (strategy=GenerationType.AUTO)
	@Column(name="RENTAL_ID")
	public Long getRentalId() {
		return mRentalId;
	}

	/**
	 * @param rentalId the rentalId to set
	 */
	public void setRentalId(Long rentalId) {
		mRentalId = rentalId;
	}

	/**
	 * @return the titleCopy
	 */
	@ManyToOne(optional=false, fetch=FetchType.EAGER)
	@JoinColumn(name="TITLE_COPY_ID")
	public TitleCopyEntity getTitleCopy() {
		return mTitleCopy;
	}

	/**
	 * @param titleCopy the titleCopy to set
	 */
	public void setTitleCopy(TitleCopyEntity titleCopy) {
		mTitleCopy = titleCopy;
	}

	/**
	 * @return the staff
	 */
	@ManyToOne(optional=false, fetch=FetchType.EAGER)
	@JoinColumn(name="STAFF_ID")
	public StaffEntity getStaff() {
		return mStaff;
	}

	/**
	 * @param staff the staff to set
	 */
	public void setStaff(StaffEntity staff) {
		mStaff = staff;
	}

	/**
	 * @return the customer
	 */
	@ManyToOne(optional=false, fetch=FetchType.EAGER)
	@JoinColumn(name="CUSTOMER_ID")
	public CustomerEntity getCustomer() {
		return mCustomer;
	}

	/**
	 * @param customer the customer to set
	 */
	public void setCustomer(CustomerEntity customer) {
		mCustomer = customer;
	}

	/**
	 * @return the firstCharge
	 */
	@Column(name="FIRST_CHARGE")
	public BigDecimal getFirstCharge() {
		return mFirstCharge;
	}

	/**
	 * @param firstCharge the firstCharge to set
	 */
	public void setFirstCharge(BigDecimal firstCharge) {
		mFirstCharge = firstCharge;
	}

	/**
	 * @return the finalCharge
	 */
	@Column(name="FINAL_CHARGE")
	public BigDecimal getFinalCharge() {
		return mFinalCharge;
	}

	/**
	 * @param finalCharge the finalCharge to set
	 */
	public void setFinalCharge(BigDecimal finalCharge) {
		mFinalCharge = finalCharge;
	}

	/**
	 * @return the rentalDate
	 */
	@Column(name="RENTAL_DATE")
	@Temporal(value=TemporalType.DATE)
	public Date getRentalDate() {
		return mRentalDate;
	}

	/**
	 * @param rentalDate the rentalDate to set
	 */
	public void setRentalDate(Date rentalDate) {
		mRentalDate = rentalDate;
	}

	/**
	 * @return the dueDate
	 */
	@Column(name="DUE_DATE")
	@Temporal(value=TemporalType.DATE)
	public Date getDueDate() {
		return mDueDate;
	}

	/**
	 * @param dueDate the dueDate to set
	 */
	public void setDueDate(Date dueDate) {
		mDueDate = dueDate;
	}

	/**
	 * @return the returnDate
	 */
	@Column(name="RETURN_DATE")
	@Temporal(value=TemporalType.DATE)
	public Date getReturnDate() {
		return mReturnDate;
	}

	/**
	 * @param returnDate the returnDate to set
	 */
	public void setReturnDate(Date returnDate) {
		mReturnDate = returnDate;
	}

	/**
	 * @return the status
	 */
	@Column(name="RENTAL_STATUS")
	public String getStatus() {
		return mStatus;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(String status) {
		mStatus = status;
	}

	
}
